package vn.vos;

import android.app.Activity;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class FlashActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        
        AndroidSystemChecking system = new AndroidSystemChecking(this);
        
        if(system.checkInstalledPackage("com.adobe.flashplayer")) {
	        /*initialize a webview*/
	        WebView webView = new WebView(this);
	        
	        /*setting for webview*/
	        WebSettings settings = webView.getSettings(); 
	        settings.setJavaScriptEnabled(true); 
	        settings.setPluginsEnabled(true); 
	        settings.setAppCacheEnabled(true); 
	        settings.setJavaScriptCanOpenWindowsAutomatically(true);
	        
	        /*load swf file*/        
	        String html ="<object width=\"550\" height=\"400\"> <param name=\"movie\" value=\"file:///android_asset/changing_tyres.swf\"> <embed src=\"file:///android_asset/whitebird1.swf\" width=\"550\" height=\"400\"> </embed> </object>";
			String mimeType = "text/html";
			String encoding = "utf-8";
			webView.loadDataWithBaseURL("null", html, mimeType, encoding, "");
			setContentView(webView);
        } else {        	
        	setContentView(R.layout.main);
        	Toast.makeText(getApplicationContext(), "Flash player WAS NOT INSTALLED YET" , Toast.LENGTH_LONG).show();
        }        
        
        if(system.isNetworkAvailable()) {
        	Toast.makeText(getApplicationContext(), "online" , Toast.LENGTH_LONG).show();
        } else {
        	Toast.makeText(getApplicationContext(), "OFFLINE" , Toast.LENGTH_LONG).show();
        }
        
        if(system.checkGPSState())
        	Toast.makeText(getApplicationContext(), "GPS is enable" , Toast.LENGTH_LONG).show();
        else
        	Toast.makeText(getApplicationContext(), "GPS is disable" , Toast.LENGTH_LONG).show();
    }
}